package day1105.second;

import day1105.common.MyUtil;
import day1105.common.Student;

import java.util.List;
import java.util.function.BinaryOperator;

import static day1105.common.MyUtil.printLine;

/**
 * @author Mr.ma
 * @since 2022/11/6 16:56
 **/
public class ReduceTest {
    public static void main(String[] args) {
        List<Student> studentList = MyUtil.createStudentList();
        studentList.stream().forEach(System.out::println);
        printLine("年龄最大的学生");
        Student student = studentList.stream().reduce(BinaryOperator.maxBy(Student::compareTo)).get();
        System.out.println("student = " + student);
        printLine("学生成绩总和");
        Double aDouble = studentList.stream().map(Student::getScore).reduce(Double::sum).get();
        System.out.println("aDouble = " + aDouble);
    }
}
